<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let y = 24
        let epsilon = 0.01
        let guess = 24 / 2
        let count = 0

        while (Math.abs(guess * guess) - y >= epsilon) {
            count += 1
            guess = guess - (((guess ** 2) - y) / (guess * 2))
        }

        console.log(count)
        console.log(guess)
    </script>
</body>

</html>